home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / x / volume3 / x11.3 / patch9 < prev    next >
Encoding:
Text File  |  1989-03-07  |  9.3 KB  |  315 lines

  1. Path: uunet!seismo!sundc!pitstop!sun!decwrl!wyse!mikew
  2. From: mikew@wyse.wyse.com (Mike Wexler)
  3. Newsgroups: comp.sources.x
  4. Subject: v03i040:  X11 Release 3, Patch9
  5. Message-ID: <2114@wyse.wyse.com>
  6. Date: 7 Mar 89 18:48:59 GMT
  7. Organization: Wyse Technology, San Jose
  8. Lines: 304
  9. Approved: mikew@wyse.com
  10.  
  11. Submitted-by: Xstuff service <xstuff@expo.lcs.mit.edu>
  12. Posting-number: Volume 3, Issue 40
  13. Archive-name: x11.3/patch9
  14.  
  15.  
  16.  
  17. The attached patch implements the recently-approved specification change
  18. to XtAddConverter to eliminate problems widget libraries are having
  19. in registering their type converters.  This is a semantic change to
  20. XtAddConverter but should be transparent to almost all applications.
  21. We do not plan to send out interim patches to the documentation; here is
  22. the description of the modification:
  23.  
  24.   Move XtAddConverter from the
  25.   compatibility section back into the main spec, and define it to mean
  26.   that the converter is added to all existing and all future (at the
  27.   time they are created) application contexts created by the calling
  28.   client, while XtAppAddConverter stays with its semantics of applying
  29.   only to the single context.
  30.  
  31. This patch also fixes an un-reported bug that will cause attempts to
  32. replace (i.e. overlay) previously registered type converters to fail.
  33.  
  34. The only applications that could be affected by this change are those which
  35. create multiple application contexts and which also use the default
  36. application context and which register differing type converters 
  37. for the same (from_type, to_type) tuple in the default context than
  38. in the other contexts.  Not many such applications are likely to exist.
  39.  
  40. Make sure your dependencies are updated when rebuilding Xt after installing
  41. this patch; since the internal application context structure has been
  42. changed, many objects need to be rebuilt.
  43.  
  44. Files:  lib/Xt/InitialI.h
  45.     lib/Xt/Convert.c
  46.     lib/Xt/Display.c
  47.  
  48. *** old/lib/Xt/InitialI.h
  49. --- lib/Xt/InitialI.h
  50. ***************
  51. *** 1,4 ****
  52. ! /* $XConsortium: InitialI.h,v 1.9 89/01/18 17:05:57 swick Exp $ */
  53.   /* $oHeader: InitializeI.h,v 1.8 88/09/01 11:25:04 asente Exp $ */
  54.   /***********************************************************
  55.   Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
  56. --- 1,4 ----
  57. ! /* $XConsortium: InitialI.h,v 1.10 89/02/23 18:56:12 swick Exp $ */
  58.   /* $oHeader: InitializeI.h,v 1.8 88/09/01 11:25:04 asente Exp $ */
  59.   /***********************************************************
  60.   Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
  61. ***************
  62. *** 78,84 ****
  63. --- 78,92 ----
  64.       int    count;
  65.   } FdStruct;
  66.   
  67. + typedef struct _ProcessContextRec {
  68. +     XtAppContext    defaultAppContext;
  69. +     XtAppContext    appContextList;
  70. +     ConverterTable    globalConverterTable;
  71. + } ProcessContextRec, *ProcessContext;
  72.   typedef struct _XtAppStruct {
  73. +     XtAppContext next;        /* link to next app in process context */
  74. +     ProcessContext process;    /* back pointer to our process context */
  75.       Display **list;
  76.       TimerEventRec *timerQueue;
  77.       WorkProcRec *workQueue;
  78. ***************
  79. *** 102,107 ****
  80. --- 110,116 ----
  81.   extern void _XtFreeConverterTable();
  82.   
  83.   extern XtAppContext _XtDefaultAppContext();
  84. + extern ProcessContext _XtGetProcessContext();
  85.   extern void _XtDestroyAppContexts();
  86.   extern void _XtCloseDisplays();
  87.   extern int _XtAppDestroyCount;
  88. *** old/lib/Xt/Convert.c
  89. --- lib/Xt/Convert.c
  90. ***************
  91. *** 1,5 ****
  92.   #ifndef lint
  93. ! static char Xrcsid[] = "$XConsortium: Convert.c,v 1.17 88/10/21 15:59:02 swick Exp $";
  94.   /* $oHeader: Convert.c,v 1.4 88/09/01 11:10:44 asente Exp $ */
  95.   #endif lint
  96.   /*LINTLIBRARY*/
  97. --- 1,5 ----
  98.   #ifndef lint
  99. ! static char Xrcsid[] = "$XConsortium: Convert.c,v 1.19 89/02/23 19:19:35 swick Exp $";
  100.   /* $oHeader: Convert.c,v 1.4 88/09/01 11:10:44 asente Exp $ */
  101.   #endif lint
  102.   /*LINTLIBRARY*/
  103. ***************
  104. *** 31,38 ****
  105.   #include    "IntrinsicI.h"
  106.   #include    "Quarks.h"
  107.   
  108. ! /* ||| */
  109.   #include    <stdio.h>
  110.   
  111.   /* Conversion procedure hash table */
  112.   
  113. --- 31,39 ----
  114.   #include    "IntrinsicI.h"
  115.   #include    "Quarks.h"
  116.   
  117. ! #ifdef DEBUG
  118.   #include    <stdio.h>
  119. + #endif
  120.   
  121.   /* Conversion procedure hash table */
  122.   
  123. ***************
  124. *** 53,61 ****
  125.   void _XtSetDefaultConverterTable(table)
  126.       ConverterTable *table;
  127.   {
  128. !     *table = (ConverterTable) XtCalloc(CONVERTHASHSIZE, 
  129. !         sizeof(ConverterPtr));
  130. !     _XtAddDefaultConverters(*table);
  131.   }
  132.   
  133.   void _XtFreeConverterTable(table)
  134. --- 54,74 ----
  135.   void _XtSetDefaultConverterTable(table)
  136.       ConverterTable *table;
  137.   {
  138. !     register ConverterTable globalConverterTable =
  139. !     _XtGetProcessContext()->globalConverterTable;
  140. !     *table = (ConverterTable) XtCalloc(CONVERTHASHSIZE, sizeof(ConverterPtr));
  141. !     _XtAddDefaultConverters(*table);
  142. !     if (globalConverterTable != (ConverterTable)NULL) {
  143. !     ConverterPtr rec;
  144. !     int i;
  145. !     for (i = CONVERTHASHSIZE; i; i--, globalConverterTable++) {
  146. !         for (rec = *globalConverterTable; rec != NULL; rec = rec->next)
  147. !            _XtTableAddConverter(*table, rec->from, rec->to, rec->converter,
  148. !                     rec->convert_args, rec->num_args);
  149. !       }
  150. !     }
  151.   }
  152.   
  153.   void _XtFreeConverterTable(table)
  154. ***************
  155. *** 105,116 ****
  156.       register ConverterPtr    p;
  157.   
  158.       pHashEntry= &table[ProcHash(from_type, to_type) & CONVERTHASHMASK];
  159. !     /* ||| Check for existing entry, overwrite if exists */
  160. !     p            = (ConverterPtr) XtMalloc(sizeof(ConverterRec));
  161. !     p->next        = *pHashEntry;
  162. !     *pHashEntry     = p;
  163. !     p->from        = from_type;
  164. !     p->to        = to_type;
  165.       p->converter    = converter;
  166.       p->convert_args = convert_args;
  167.       p->num_args     = num_args;
  168. --- 118,134 ----
  169.       register ConverterPtr    p;
  170.   
  171.       pHashEntry= &table[ProcHash(from_type, to_type) & CONVERTHASHMASK];
  172. !     for (p = *pHashEntry; p != NULL; p = p->next) {
  173. !     if (p->from == from_type && p->to == to_type) break;
  174. !     }
  175. !     if (p == NULL) {
  176. !     p = (ConverterPtr) XtMalloc(sizeof(ConverterRec));
  177. !     p->next        = *pHashEntry;
  178. !     *pHashEntry     = p;
  179. !     p->from        = from_type;
  180. !     p->to        = to_type;
  181. !     }
  182.       p->converter    = converter;
  183.       p->convert_args = convert_args;
  184.       p->num_args     = num_args;
  185. ***************
  186. *** 122,129 ****
  187.       XtConvertArgList    convert_args;
  188.       Cardinal        num_args;
  189.   {
  190. !     XtAppAddConverter(_XtDefaultAppContext(),
  191. !         from_type, to_type, converter, convert_args, num_args);
  192.   }
  193.   
  194.   void XtAppAddConverter(app, from_type, to_type, converter, convert_args, num_args)
  195. --- 140,161 ----
  196.       XtConvertArgList    convert_args;
  197.       Cardinal        num_args;
  198.   {
  199. !     ProcessContext process = _XtGetProcessContext();
  200. !     XtAppContext app = process->appContextList;
  201. !     XrmRepresentation from = XrmStringToRepresentation(from_type);
  202. !     XrmRepresentation to = XrmStringToRepresentation(to_type);
  203. !     if (process->globalConverterTable == (ConverterTable)NULL) {
  204. !     process->globalConverterTable =
  205. !         (ConverterTable) XtCalloc(CONVERTHASHSIZE, sizeof(ConverterPtr));
  206. !     }
  207. !     _XtTableAddConverter(process->globalConverterTable, from, to,
  208. !              converter, convert_args, num_args);
  209. !     while (app != (XtAppContext)NULL) {
  210. !     _XtTableAddConverter(app->converterTable, from, to, converter,
  211. !                  convert_args, num_args);
  212. !     app = app->next;
  213. !     }
  214.   }
  215.   
  216.   void XtAppAddConverter(app, from_type, to_type, converter, convert_args, num_args)
  217. ***************
  218. *** 182,187 ****
  219. --- 214,220 ----
  220.   }
  221.   
  222.   
  223. + #ifdef DEBUG
  224.   void CacheStats()
  225.   {
  226.       register Cardinal i;
  227. ***************
  228. *** 205,210 ****
  229. --- 238,244 ----
  230.       }
  231.       }
  232.   }
  233. + #endif /*DEBUG*/
  234.   
  235.   static Boolean ResourceQuarkToOffset(widget_class, name, offset)
  236.       WidgetClass widget_class;
  237. *** old/lib/Xt/Display.c
  238. --- lib/Xt/Display.c
  239. ***************
  240. *** 1,5 ****
  241.   #ifndef lint
  242. ! static char Xrcsid[] = "$XConsortium: Display.c,v 1.14 88/09/26 08:33:02 swick Exp $";
  243.   /* $oHeader: Display.c,v 1.9 88/09/01 11:28:47 asente Exp $ */
  244.   #endif lint
  245.   
  246. --- 1,5 ----
  247.   #ifndef lint
  248. ! static char Xrcsid[] = "$XConsortium: Display.c,v 1.15 89/02/23 18:56:58 swick Exp $";
  249.   /* $oHeader: Display.c,v 1.9 88/09/01 11:28:47 asente Exp $ */
  250.   #endif lint
  251.   
  252. ***************
  253. *** 31,44 ****
  254.   #include <sys/param.h>
  255.   #include "IntrinsicI.h"
  256.   
  257. ! static XtAppContext defaultAppContext = NULL;
  258.   
  259.   XtAppContext _XtDefaultAppContext()
  260.   {
  261. !     if (defaultAppContext == NULL) {
  262. !         defaultAppContext = XtCreateApplicationContext();
  263. !     }
  264. !     return defaultAppContext;
  265.   }
  266.   
  267.   static void XtAddToAppContext(d, app)
  268. --- 31,55 ----
  269.   #include <sys/param.h>
  270.   #include "IntrinsicI.h"
  271.   
  272. ! ProcessContext _XtGetProcessContext()
  273. ! {
  274. !     static ProcessContextRec processContextRec = {
  275. !     (XtAppContext)NULL,
  276. !     (XtAppContext)NULL,
  277. !     (ConverterTable)NULL
  278. !     };
  279.   
  280. +     return &processContextRec;
  281. + }
  282.   XtAppContext _XtDefaultAppContext()
  283.   {
  284. !     register ProcessContext process = _XtGetProcessContext();
  285. !     if (process->defaultAppContext == NULL) {
  286. !     process->defaultAppContext = XtCreateApplicationContext();
  287. !     }
  288. !     return process->defaultAppContext;
  289.   }
  290.   
  291.   static void XtAddToAppContext(d, app)
  292. ***************
  293. *** 210,215 ****
  294. --- 221,229 ----
  295.   {
  296.       XtAppContext app = XtNew(XtAppStruct);
  297.   
  298. +     app->process = _XtGetProcessContext();
  299. +     app->next = app->process->appContextList;
  300. +     app->process->appContextList = app;
  301.       app->list = NULL;
  302.       app->count = app->max = app->last = 0;
  303.       app->timerQueue = NULL;
  304.  
  305. -- 
  306. Mike Wexler(wyse!mikew)    Phone: (408)433-1000 x1330
  307. Moderator of comp.sources.x
  308.